import org.junit.Test;

import java.util.function.Consumer;
import java.util.function.Supplier;

/**
 * @author 35326
 * 2021/3/25 17:54
 * 函数式接口的使用和测试
 */
public class FunctionalTest {
	public static void main(String[] args) {

	}

	@Test
	public void test1(){
		getHappyTime(()-> 20);
		happyTime(20,money->
			System.out.println("我得到了"+money+"K的月薪，我很满意！")
		);
	}

	<T> void happyTime(int money, Consumer<Integer> consumer){
		consumer.accept(money);
	}

	<T> T getHappyTime(Supplier<T> supplier){
		T result=supplier.get();
		System.out.println("通过自己的努力得到了"+result+"的月薪！！");
		return  result;
	}
}
